package org.zjt.orika;

import ma.glasnost.orika.BoundMapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.ConfigurableMapper;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.util.Date;

/**
 * Created by Administrator on 2017/6/13.
 */
public class Mapper  {
    protected void configure(MapperFactory factory) {
        factory.classMap(Person.class, PersonDto.class)
                .field("name.first", "firstName")
                .field("name.last", "lastName")
                .field("knownAliases{first}", "aliases{[0]}")
                .field("knownAliases{last}", "aliases{[1]}")
                .byDefault()
                .register();
    }


    public static void main(String[] args) {
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        mapperFactory.classMap(Person.class, PersonDto.class)
                .field("name.first", "firstName")
                .field("name.last", "lastName")
                .field("knownAliases{first}", "aliases{[0]}")
                .field("knownAliases{last}", "aliases{[1]}")
                .byDefault()
                .register();
        BoundMapperFacade<PersonDto, Person> mapperFacade = mapperFactory.getMapperFacade(PersonDto.class, Person.class);

        PersonDto personDTO = new PersonDto("zhang","juntao",new Date(),new String[][]{ {"1","2"}, {"4","5"} });
        Person map = mapperFacade.map(personDTO);
        System.out.println(map.getName());
        
    }
}